package com.dingding.web.url.action;

import javax.annotation.Resource;

import com.dingding.common.core.exception.bussiness.BussinessException;
import com.dingding.facade.user.dto.common.driver.ReqSyncDriverAuthStateDTO;
import com.dingding.facade.user.dto.common.driver.ResSyncDriverAuthStateDTO;
import com.dingding.facade.user.facade.common.driver.IDriverFacade;
import com.dingding.web.base.action.BaseAction;

public class UrlAction  extends BaseAction{

	private static final long serialVersionUID = -4799393754357341888L;

	@Resource(name = "driverFacade")
	private IDriverFacade driverFacade;
	
	private String userId;
	
	/**
	 * 
	 * @Title: toAuthPage
	 * @Description: 根据用户id查询用户审核状态并跳转到相应的页面
	 * @param @return  参数说明 
	 * @return String    返回类型 
	 * @throws
	 */
	public String toAuthPage() {

		String userId = getPara("userId");
		ReqSyncDriverAuthStateDTO reqSyncDriverAuthStateDTO = new ReqSyncDriverAuthStateDTO(userId);
		ResSyncDriverAuthStateDTO result = null;
		try {
			result = driverFacade.getResSyncDriverAuthState(reqSyncDriverAuthStateDTO);
		} catch (BussinessException e) {//业务逻辑异常
			return NONE;
		} catch (Exception e) {//服务器级别异常
			log.error(e);
			return NONE;
		}
		//0:未认证 1：审核中 2：审核通过 3：审核未通过
		if(result.getSuvStatus() == 0) {
			return "unauthorized";
		}
		if(result.getSuvStatus() == 1) {
			return "inview";
		}
		if(result.getSuvStatus() == 2) {
			return "auditpass";
		}
		if(result.getSuvStatus() == 3) {
			return "auditnotpass";
		}
		return NONE;
	}
	
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	
}
